package net.magicalcloud.magicalcloud;

import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;

import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import net.magicalcloud.magicalcloud.entity.User;

/**
 *
 */

public class AppApplication extends MultiDexApplication {

    private static Context mContext;

    private static User currentUser;


    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);

    }

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();

        //初始化image loader
        initImageLoader();

    }


    private void initImageLoader() {
        ImageLoaderConfiguration configuration =  ImageLoaderConfiguration.createDefault(this);
        ImageLoader.getInstance().init(configuration);
    }

    /**
     * 获取当前登陆用户
     * @return 当前用户
     */
    public static User getCurrentUser() {

        if(currentUser==null){
            currentUser=new User();
            currentUser.setId(1234655);
        }
        return currentUser;
    }

    /**
     * 设置登陆用户 在登录成功时应当调用
     * @param currentUser 用户
     */
    public static void setCurrentUser(User currentUser) {
        currentUser = currentUser;
    }
}
